<?php get_header(); ?>
	<div id="container">
		<div id="content">

<?php while (have_posts()) : the_post(); ?>
<?php
	$options=get_option('dkret3');
	$items=$wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_type = 'attachment'" );
	if( (in_category( $options['gallery_cat_id'] )) && (($options['showgallery']) == '1') && ($items > '0') ) {
?>
			<div id="post-<?php the_ID(); ?>" <?php post_class('gallery-post home') ?>>

				<div class="entry-header">
					<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s', 'dkret'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title(); ?></a></h2>
					<div class="entry-date"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO'); ?>"><?php unset($previousday); printf(__('%1$s &#8211; %2$s', 'dkret'), the_date('', '', '', false), get_the_time()) ?></abbr></div>
				</div><!-- .entry-header -->

				<div class="entry-content">
				
<?php if ($items > '0') { ?>
				<div class="entry-image wp-caption">
					<a href="<?php permalink_link() ?>"><?php $hilite = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_type = 'attachment' LIMIT 1" ); echo wp_get_attachment_image( $hilite, 'thumbnail' ); ?></a>
					<p class="wp-caption-text"><?php printf(__('This album contains <strong>%s</strong> items.', 'dkret'), $items ) ?></p>
				</div><!-- .entry-gallery-image -->
<?php } ?>				

					<?php the_excerpt(''); ?>

				</div><!-- .entry-content -->
				
				<?php edit_post_link(__('Edit', 'dkret'), "<span class=\"edit-link\">", "</span>"); ?>					

			</div><!-- #post- -->

<?php } else { // If it's a regular post or a permalink page ?>

			<div id="post-<?php the_ID(); ?>" <?php post_class('home') ?>>

				<div class="entry-header">

					<div class="entry-calendar-date">
						<?php the_time('M') ?>
						<span class="entry-calendar-day"><?php the_time('d') ?></span>
						<span class="entry-calendar-year"><?php the_time('Y') ?></span>
					</div><!-- .entry-calendar-date -->

					<h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s', 'dkret'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title(); ?></a></h2>
					<div class="entry-date"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO'); ?>"><?php unset($previousday); printf(__('%1$s &#8211; %2$s', 'dkret'), the_date('', '', '', false), get_the_time()) ?></abbr></div>
					<div class="entry-meta-above">
						<span class="author vcard"><span class="icontext"><?php _e('By','dkret') ?></span><?php the_author_posts_link() ?></span>
						<span class="meta-sep">|</span>
						<span class="cat-links"><span class="icontext"><?php _e('Posted in','dkret') ?></span><?php the_category(', ') ?></span>
						<span class="meta-sep">|</span>
						<?php the_tags('<span class="tag-links"><span class="icontext">' . __('Tagged','dkret') . '</span> ', ', ', '</span><span class="meta-sep">|</span>'); ?>
						<span class="comments-link"><?php comments_popup_link(__('Comments (0)','dkret'), __('Comments (1)','dkret'), __('Comments (%)','dkret'),'', __('Comments off','dkret') ); ?></span>
					</div><!-- .entry-meta-above -->
				</div><!-- .entry-header -->

				<div class="entry-content">

					<?php the_content(''.__('Read More <span class="meta-nav">&raquo;</span>', 'dkret').''); ?>

					<?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'dkret') . '&after=</div>') ?>
				</div><!-- .entry-content -->

				<div class="entry-meta">
					<span class="author vcard"><span class="icontext"><?php _e('By','dkret') ?></span><?php the_author_posts_link() ?></span>
					<span class="meta-sep">|</span>
					<span class="cat-links"><span class="icontext"><?php _e('Posted in','dkret') ?></span><?php the_category(', ') ?></span>
					<span class="meta-sep">|</span>
					<?php the_tags('<span class="tag-links"><span class="icontext">' . __('Tagged','dkret') . '</span> ', ', ', '</span><span class="meta-sep">|</span>'); ?>
					<span class="comments-link"><?php comments_popup_link(__('Comments (0)','dkret'), __('Comments (1)','dkret'), __('Comments (%)','dkret'),'', __('Comments off','dkret') ); ?></span>
				</div>

				<?php edit_post_link(__('Edit', 'dkret'), "<span class=\"edit-link\">", "</span>"); ?>

			</div><!-- #post-??ID -->
<?php } ?>

<?php endwhile ?>

<?php if(function_exists('wp_pagenavi')) :
		wp_pagenavi();
	else : ?>
			<div id="nav" class="navigation">
				<?php next_posts_link(__('<span class="nav-previous"><span class="meta-nav">&laquo;</span> Older posts</span>', 'dkret')) ?>
				<?php previous_posts_link(__('<span class="nav-next">Newer posts <span class="meta-nav">&raquo;</span></span>', 'dkret')) ?>
			</div><!-- #nav .navigation -->

<?php endif; ?>

		</div><!-- #content -->
	</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>